#!/usr/bin/env python

import sys
import socket, struct
import time

def main():
    maps4Pv = {}
    maps4Uv = {}
    
    for line in sys.stdin:
        try:
            s = line.strip().split('::')
            page = s[0]
            ip = ip2long(s[1])
            
            if not maps4Pv.has_key(page):
                maps4Pv[page] = 1
            else:
                maps4Pv[page] = maps4Pv[page] + 1
            
            if not maps4Uv.has_key(page):
                maps4Uv[page] = set()

            if ip not in maps4Uv[page]:
                maps4Uv[page].add(ip)
                
        except Exception,ex:
            print >> sys.stderr, ex
            continue
    
    lst = sorted(maps4Pv.items(), lambda x, y: cmp(x[1], y[1]), reverse=True) 
    pvsum = 0
    
    for k in lst:
        if k[1] == 1: continue #just ignore page which visit count less than 2
        pvsum = pvsum + k[1]
        print('%-06d %s'%(k[1], k[0]))
    print('pv sum:%d'%pvsum)
    
    print('----------')
    uvsum = 0
    for (k, v) in maps4Uv.items():
        oneuv = len(v)
        if oneuv == 1: continue #as same as above
        uvsum = uvsum + oneuv
        print('%-06d %s'%(oneuv, k))
    print('uv sum:%d'%uvsum)
    
zInetAton = socket.inet_aton
zUnpack = struct.unpack

def ip2long(ip):
    packedIP = zInetAton(ip)
    return zUnpack("!L", packedIP)[0]
            
if __name__ == "__main__":
    main()